<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>5 元素居中：table-cell</title>
  <style>
    .parent {
      width: 200px;
      height: 200px;
      background: #ccc;
      /* 缺点：导致父元素的文本内容也垂直方向居中显示 */
      display: table-cell;
      vertical-align: middle;
    }

    .child {
      width: 100px;
      height: 100px;
      background: #e00;
      margin: 0 auto;
    }
  </style>
</head>

<body>
  <div class="parent">parent...
    <div class="child">child...</div>
  </div>
</body>

</html>